﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Aliyun.MQS.SDK
{
    public static class OptionExtensions
    {
        public static void WriteToStreamAsXml(this CreatingQueueOption obj, TextWriter writer)
        {
            writer.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
            writer.WriteLine("<Queue xmlns=\"http://mqs.aliyuncs.com/doc/v1/\">");
            writer.WriteLine(string.Format("<DelaySeconds>{0}</DelaySeconds>", obj.DelaySeconds));
            writer.WriteLine(string.Format("<MaximumMessageSize>{0}</MaximumMessageSize>", obj.MaximumMessageSize));
            writer.WriteLine(string.Format("<MessageRetentionPeriod>{0}</MessageRetentionPeriod>", obj.MessageRetentionPeriod));
            writer.WriteLine(string.Format("<VisibilityTimeout>{0}</VisibilityTimeout>", obj.VisibilityTimeout));
            writer.WriteLine(string.Format("<PollingWaitSeconds>{0}</PollingWaitSeconds>", obj.PollingWaitSeconds));
            writer.WriteLine("</Queue>");
        }

        public static void WriteToStreamAsXml(this SendMessageOption obj, TextWriter writer)
        {
            writer.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
            writer.WriteLine("<Message xmlns=\"http://mqs.aliyuncs.com/doc/v1/\">");
            writer.WriteLine(string.Format("<MessageBody>{0}</MessageBody>", obj.MessageBody));
            writer.WriteLine(string.Format("<DelaySeconds>{0}</DelaySeconds>", obj.DelaySeconds));
            writer.WriteLine(string.Format("<Priority>{0}</Priority>", obj.Priority));
            writer.WriteLine("</Message>");
        }
    }
}
